package com.bianyuanren.v4.controller.txmap;

import com.bianyuanren.common.core.domain.AjaxResult;
import com.bianyuanren.v4.utils.HttpUtils;
import com.bianyuanren.v4.utils.JsonUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/txmap")
public class TxMapController {


    /**
     * 腾讯地图通过经纬度获取地址
     * longitude 经度
     * latitude 纬度
     */
    @PostMapping("/location")
    @ResponseBody
    public AjaxResult location(double longitude,double latitude){
        String url="https://apis.map.qq.com/ws/geocoder/v1/";
        String key="key=YAVBZ-EMRW6-G4ASN-E74N5-I7J4O-Z5FTQ&get_poi=1"; //边缘人
        String utl1=url+"?location="+longitude+","+latitude+"&"+key;
//        String url="https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=63OBZ-KF2KX-AOP4Z-Z26N2-FLP5J-JCFTZ&get_poi=1";
        String s = HttpUtils.doGet(utl1);
        Object json = JsonUtils.fromJson(s, Object.class);
        return AjaxResult.success("success",json);
    }
}
